/**
 * 系统平台
 * moonvip_admin
 * com.tz.web.receiptaddress
 * ReceiptAddressController.java
 * 创建人:小胡
 * 时间：2017年01月17日 16:51:55
 *
 */
package com.tz.web.receiptaddress;
import com.tz.auth.AuthPassport;
import com.tz.bean.ReceiptAddress;
import com.tz.bean.TzParams;
import com.tz.service.receiptaddress.IReceiptAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;

/**
 * 用户收货地址管理web
 * ReceiptAddressController
 * 创建人:小胡
 * 时间：2017年01月17日 16:51:55
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/admin/user/receiptaddress")
public class ReceiptAddressController {
	
	@Autowired
	private IReceiptAddressService receiptaddressService;

	/*列表查询*/
	@AuthPassport
	@RequestMapping("/list")
	public String list(TzParams params){
		return "user/receiptaddress/list";
	}

    /*模板页面*/
	@RequestMapping("/template")
	public String template(TzParams params ,Model model){
		model.addAttribute("datas", receiptaddressService.findReceiptAddresss(params));
		model.addAttribute("itemCount", receiptaddressService.count(params));
		return "user/receiptaddress/template";
	}

	@ResponseBody
	@RequestMapping(value="/update",method= RequestMethod.POST)
	public String update(ReceiptAddress receiptaddress){
		receiptaddressService.update(receiptaddress);
		return "success";
	}

	@ResponseBody
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	public String delete(TzParams params){
		receiptaddressService.delete(params);
		return "success";
	}

	@RequestMapping("/add")
    public String add(TzParams params){
		return "user/receiptaddress/add";
   }


	@RequestMapping(value = "/edit/{id}" ,method = RequestMethod.GET)
    public String edit(@PathVariable("id") Integer id , Model model){
		HashMap<String ,Object> receiptaddress = receiptaddressService.getReceiptAddress(id);
		model.addAttribute("receiptaddress",receiptaddress);
		return "user/receiptaddress/edit";
	}
}
